<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Method::Signatures - method and function declarations with signatures and no source filter - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Method-Signatures - MetaCPAN" href="https://metacpan.org/dist/Method-Signatures/releases.rss" />
        <link rel="canonical" href="./Method::Signatures.html" />
        <meta name="description" content="method and function declarations with signatures and no source filter" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Method::Signatures" />
<meta name="twitter:title"       content="Method::Signatures" />
<meta name="twitter:description" content="method and function declarations with signatures and no source filter" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Method::Signatures.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Method-Signatures was released.">
      <span class="relatize">11 Feb 2017 21:41:28 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Method-Signatures">Method-Signatures</a>
  </li>
  <li>
    Module version: 20170211
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Method-Signatures/source/lib/Method/Signatures.pm">Source</a>
    (<a href="https://metacpan.org/dist/Method-Signatures/source/lib/Method/Signatures.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Method-Signatures/source/lib/Method">Browse</a>
    (<a href="https://metacpan.org/dist/Method-Signatures/source/lib/Method?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Method-Signatures/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Method-Signatures/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/evalEmpire/method-signatures">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="http://rt.cpan.org/NoAuth/Bugs.html?Dist=Method-Signatures">Issues</a>
      (12)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Method-Signatures+20170211" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/M/Method-Signatures.html?oncpan=1&amp;distmat=1&amp;version=20170211&amp;grade=2" style="color: #090">20</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/M/Method-Signatures.html?oncpan=1&amp;distmat=1&amp;version=20170211&amp;grade=3" style="color: #900">28</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/M/Method-Signatures.html?oncpan=1&amp;distmat=1&amp;version=20170211&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/BAREFOOT/Method-Signatures-20170211">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Method-Signatures who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Method-Signatures-20170211/index.html">89.86% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.8.1
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Method-Signatures/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/B/BA/BAREFOOT/Method-Signatures-20170211.tar.gz">
      Download (<span itemprop="fileSize">81.68KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FBAREFOOT%2FMethod-Signatures-20170211%2Flib%2FMethod%2FSignatures.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Method-Signatures/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Method-Signatures/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Method-Signatures">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Method-Signatures">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Method/Signatures.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="BAREFOOT/Method-Signatures-20170211"
>20170211
  (BAREFOOT on 2017-02-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140224"
>20140224
  (BAREFOOT on 2014-02-24)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121201"
>20121201
  (BAREFOOT on 2012-12-01)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923.1726"
>20110923.1726
  (MSCHWERN on 2011-09-24)</option>
<optgroup label="BackPAN">'
<option
  
  value="BAREFOOT/Method-Signatures-20160608.0051_002"
>20160608.0051_002 DEV
  (BAREFOOT on 2016-06-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160516.2032_001"
>20160516.2032_001 DEV
  (BAREFOOT on 2016-05-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160315"
>20160315
  (BAREFOOT on 2016-03-15)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160310.2049_001"
>20160310.2049_001 DEV
  (BAREFOOT on 2016-03-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20151120.1519_001"
>20151120.1519_001 DEV
  (BAREFOOT on 2015-11-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20141021"
>20141021
  (BAREFOOT on 2014-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140920.1910_001"
>20140920.1910_001 DEV
  (BAREFOOT on 2014-09-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140806.0226_001"
>20140806.0226_001 DEV
  (BAREFOOT on 2014-08-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140220.0106_001"
>20140220.0106_001 DEV
  (BAREFOOT on 2014-02-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131010"
>20131010
  (BAREFOOT on 2013-10-10)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131007.0002_002"
>20131007.0002_002 DEV
  (BAREFOOT on 2013-10-07)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131004.0159_001"
>20131004.0159_001 DEV
  (BAREFOOT on 2013-10-04)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130505"
>20130505
  (BAREFOOT on 2013-05-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130427.0031_001"
>20130427.0031_001 DEV
  (BAREFOOT on 2013-04-27)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130222"
>20130222
  (BAREFOOT on 2013-02-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130218.1447_001"
>20130218.1447_001 DEV
  (BAREFOOT on 2013-02-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130216.1729_001"
>20130216.1729_001 DEV
  (BAREFOOT on 2013-02-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121219.0033_001"
>20121219.0033_001 DEV
  (BAREFOOT on 2012-12-19)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121128.2139_001"
>20121128.2139_001 DEV
  (BAREFOOT on 2012-11-29)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121108.0047_001"
>20121108.0047_001 DEV
  (BAREFOOT on 2012-11-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121025.2315_001"
>20121025.2315_001 DEV
  (BAREFOOT on 2012-10-26)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120523"
>20120523
  (BAREFOOT on 2012-05-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120517"
>20120517
  (BAREFOOT on 2012-05-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120514.0117_001"
>20120514.0117_001 DEV
  (BAREFOOT on 2012-05-14)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111125"
>20111125
  (BAREFOOT on 2011-11-25)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111020"
>20111020
  (BAREFOOT on 2011-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111017.2055_002"
>20111017.2055_002 DEV
  (BAREFOOT on 2011-10-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20110927.2305_001"
>20110927.2305_001 DEV
  (BAREFOOT on 2011-09-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923"
>20110923
  (MSCHWERN on 2011-09-23)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110324.1600_001"
>20110324.1600_001 DEV
  (MSCHWERN on 2011-03-24)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110322.0027_001"
>20110322.0027_001 DEV
  (MSCHWERN on 2011-03-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110216.1153_01"
>20110216.1153_01 DEV
  (MSCHWERN on 2011-02-16)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20100730"
>20100730
  (MSCHWERN on 2010-07-31)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20090620"
>20090620
  (MSCHWERN on 2009-06-20)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081028"
>20081028
  (MSCHWERN on 2008-10-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021.1911"
>20081021.1911
  (MSCHWERN on 2008-10-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021"
>20081021
  (MSCHWERN on 2008-10-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081008"
>20081008
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081007"
>20081007
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081006"
>20081006
  (MSCHWERN on 2008-10-06)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.11"
>0.11
  (MSCHWERN on 2008-09-27)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.10"
>0.10
  (MSCHWERN on 2008-09-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.05"
>0.05
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.04"
>0.04
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.03"
>0.03
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.02"
>0.02
  (MSCHWERN on 2007-12-26)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.01"
>0.01
  (MSCHWERN on 2007-12-26)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/BAREFOOT/Method-Signatures-20170211/diff/' + encodeURIComponent(this.value) + '/lib/Method/Signatures.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="BAREFOOT/Method-Signatures-20170211"
>20170211
  (BAREFOOT on 2017-02-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140224"
>20140224
  (BAREFOOT on 2014-02-24)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121201"
>20121201
  (BAREFOOT on 2012-12-01)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923.1726"
>20110923.1726
  (MSCHWERN on 2011-09-24)</option>
<optgroup label="BackPAN">'
<option
  
  value="BAREFOOT/Method-Signatures-20160608.0051_002"
>20160608.0051_002 DEV
  (BAREFOOT on 2016-06-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160516.2032_001"
>20160516.2032_001 DEV
  (BAREFOOT on 2016-05-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160315"
>20160315
  (BAREFOOT on 2016-03-15)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160310.2049_001"
>20160310.2049_001 DEV
  (BAREFOOT on 2016-03-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20151120.1519_001"
>20151120.1519_001 DEV
  (BAREFOOT on 2015-11-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20141021"
>20141021
  (BAREFOOT on 2014-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140920.1910_001"
>20140920.1910_001 DEV
  (BAREFOOT on 2014-09-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140806.0226_001"
>20140806.0226_001 DEV
  (BAREFOOT on 2014-08-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140220.0106_001"
>20140220.0106_001 DEV
  (BAREFOOT on 2014-02-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131010"
>20131010
  (BAREFOOT on 2013-10-10)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131007.0002_002"
>20131007.0002_002 DEV
  (BAREFOOT on 2013-10-07)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131004.0159_001"
>20131004.0159_001 DEV
  (BAREFOOT on 2013-10-04)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130505"
>20130505
  (BAREFOOT on 2013-05-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130427.0031_001"
>20130427.0031_001 DEV
  (BAREFOOT on 2013-04-27)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130222"
>20130222
  (BAREFOOT on 2013-02-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130218.1447_001"
>20130218.1447_001 DEV
  (BAREFOOT on 2013-02-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130216.1729_001"
>20130216.1729_001 DEV
  (BAREFOOT on 2013-02-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121219.0033_001"
>20121219.0033_001 DEV
  (BAREFOOT on 2012-12-19)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121128.2139_001"
>20121128.2139_001 DEV
  (BAREFOOT on 2012-11-29)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121108.0047_001"
>20121108.0047_001 DEV
  (BAREFOOT on 2012-11-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121025.2315_001"
>20121025.2315_001 DEV
  (BAREFOOT on 2012-10-26)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120523"
>20120523
  (BAREFOOT on 2012-05-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120517"
>20120517
  (BAREFOOT on 2012-05-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120514.0117_001"
>20120514.0117_001 DEV
  (BAREFOOT on 2012-05-14)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111125"
>20111125
  (BAREFOOT on 2011-11-25)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111020"
>20111020
  (BAREFOOT on 2011-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111017.2055_002"
>20111017.2055_002 DEV
  (BAREFOOT on 2011-10-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20110927.2305_001"
>20110927.2305_001 DEV
  (BAREFOOT on 2011-09-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923"
>20110923
  (MSCHWERN on 2011-09-23)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110324.1600_001"
>20110324.1600_001 DEV
  (MSCHWERN on 2011-03-24)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110322.0027_001"
>20110322.0027_001 DEV
  (MSCHWERN on 2011-03-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110216.1153_01"
>20110216.1153_01 DEV
  (MSCHWERN on 2011-02-16)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20100730"
>20100730
  (MSCHWERN on 2010-07-31)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20090620"
>20090620
  (MSCHWERN on 2009-06-20)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081028"
>20081028
  (MSCHWERN on 2008-10-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021.1911"
>20081021.1911
  (MSCHWERN on 2008-10-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021"
>20081021
  (MSCHWERN on 2008-10-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081008"
>20081008
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081007"
>20081007
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081006"
>20081006
  (MSCHWERN on 2008-10-06)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.11"
>0.11
  (MSCHWERN on 2008-09-27)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.10"
>0.10
  (MSCHWERN on 2008-09-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.05"
>0.05
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.04"
>0.04
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.03"
>0.03
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.02"
>0.02
  (MSCHWERN on 2007-12-26)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.01"
>0.01
  (MSCHWERN on 2007-12-26)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Any::Moose" title="Any::Moose" class="ellipsis">Any::Moose</a></li>
  <li><a href="https://metacpan.org/pod/Const::Fast" title="Const::Fast" class="ellipsis">Const::Fast</a></li>
  <li><a href="https://metacpan.org/pod/Devel::Declare" title="Devel::Declare" class="ellipsis">Devel::Declare</a></li>
  <li><a href="https://metacpan.org/pod/Devel::Declare::MethodInstaller::Simple" title="Devel::Declare::MethodInstaller::Simple" class="ellipsis">Devel::Declare::MethodInstaller::Simple</a></li>
  <li><a href="https://metacpan.org/pod/Lexical::SealRequireHints" title="Lexical::SealRequireHints" class="ellipsis">Lexical::SealRequireHints</a></li>
  <li><a href="https://metacpan.org/pod/Mouse" title="Mouse" class="ellipsis">Mouse</a></li>
  <li><a href="https://metacpan.org/pod/PPI" title="PPI" class="ellipsis">PPI</a></li>
  <li><a href="./Sub::Name.html" title="Sub::Name" class="ellipsis">Sub::Name</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Method::Signatures/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Method%3A%3ASignatures">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Method-Signatures">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/BAREFOOT/Method-Signatures-20170211/view/lib/Method/Signatures.pm">This version</a>
    </li>
    <li>
      <a href="./Method::Signatures.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/PAVELSR"><img src="https://www.gravatar.com/avatar/bdd3233525e2a6ca61bbc05752111c15?d=identicon&amp;s=20" title="PAVELSR" alt="PAVELSR"></a>
<a class="display-all" href="https://metacpan.org/author/SSCAFFIDI"><img src="https://www.gravatar.com/avatar/2b2258ad3913c3d9a32123b905101a8b?d=identicon&amp;s=20" title="SSCAFFIDI" alt="SSCAFFIDI"></a>
<a class="display-all" href="https://metacpan.org/author/IOANR"><img src="https://www.gravatar.com/avatar/98ca06f241752dc58bf366e44e1f1b84?d=identicon&amp;s=20" title="IOANR" alt="IOANR"></a>
<a class="display-all" href="https://metacpan.org/author/DCPETROV"><img src="https://www.gravatar.com/avatar/10e265a667839a004d83dd3ed6b6cfc9?d=identicon&amp;s=20" title="DCPETROV" alt="DCPETROV"></a>
<a class="display-all" href="https://metacpan.org/author/SYP"><img src="https://www.gravatar.com/avatar/9b6fa62677be03c25ee1af4d95472042?d=identicon&amp;s=20" title="SYP" alt="SYP"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Method-Signatures/plussers">23 PAUSE users</a>
</div>
<div>
    17 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 1 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
      data-contrib-email="schwern@pobox.com"
    >
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=identicon&amp;s=20" />
      Michael G Schwern
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/BAREFOOT" class="author-name">Buddy Burden</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Method/Signatures.pm&#39;" class="">
<option
  selected
  value="BAREFOOT/Method-Signatures-20170211"
>20170211
  (BAREFOOT on 2017-02-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140224"
>20140224
  (BAREFOOT on 2014-02-24)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121201"
>20121201
  (BAREFOOT on 2012-12-01)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923.1726"
>20110923.1726
  (MSCHWERN on 2011-09-24)</option>
<optgroup label="BackPAN">'
<option
  
  value="BAREFOOT/Method-Signatures-20160608.0051_002"
>20160608.0051_002 DEV
  (BAREFOOT on 2016-06-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160516.2032_001"
>20160516.2032_001 DEV
  (BAREFOOT on 2016-05-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160315"
>20160315
  (BAREFOOT on 2016-03-15)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20160310.2049_001"
>20160310.2049_001 DEV
  (BAREFOOT on 2016-03-11)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20151120.1519_001"
>20151120.1519_001 DEV
  (BAREFOOT on 2015-11-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20141021"
>20141021
  (BAREFOOT on 2014-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140920.1910_001"
>20140920.1910_001 DEV
  (BAREFOOT on 2014-09-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140806.0226_001"
>20140806.0226_001 DEV
  (BAREFOOT on 2014-08-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20140220.0106_001"
>20140220.0106_001 DEV
  (BAREFOOT on 2014-02-20)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131010"
>20131010
  (BAREFOOT on 2013-10-10)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131007.0002_002"
>20131007.0002_002 DEV
  (BAREFOOT on 2013-10-07)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20131004.0159_001"
>20131004.0159_001 DEV
  (BAREFOOT on 2013-10-04)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130505"
>20130505
  (BAREFOOT on 2013-05-06)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130427.0031_001"
>20130427.0031_001 DEV
  (BAREFOOT on 2013-04-27)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130222"
>20130222
  (BAREFOOT on 2013-02-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130218.1447_001"
>20130218.1447_001 DEV
  (BAREFOOT on 2013-02-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20130216.1729_001"
>20130216.1729_001 DEV
  (BAREFOOT on 2013-02-17)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121219.0033_001"
>20121219.0033_001 DEV
  (BAREFOOT on 2012-12-19)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121128.2139_001"
>20121128.2139_001 DEV
  (BAREFOOT on 2012-11-29)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121108.0047_001"
>20121108.0047_001 DEV
  (BAREFOOT on 2012-11-08)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20121025.2315_001"
>20121025.2315_001 DEV
  (BAREFOOT on 2012-10-26)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120523"
>20120523
  (BAREFOOT on 2012-05-23)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120517"
>20120517
  (BAREFOOT on 2012-05-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20120514.0117_001"
>20120514.0117_001 DEV
  (BAREFOOT on 2012-05-14)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111125"
>20111125
  (BAREFOOT on 2011-11-25)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111020"
>20111020
  (BAREFOOT on 2011-10-21)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20111017.2055_002"
>20111017.2055_002 DEV
  (BAREFOOT on 2011-10-18)</option>
<option
  
  value="BAREFOOT/Method-Signatures-20110927.2305_001"
>20110927.2305_001 DEV
  (BAREFOOT on 2011-09-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110923"
>20110923
  (MSCHWERN on 2011-09-23)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110324.1600_001"
>20110324.1600_001 DEV
  (MSCHWERN on 2011-03-24)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110322.0027_001"
>20110322.0027_001 DEV
  (MSCHWERN on 2011-03-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20110216.1153_01"
>20110216.1153_01 DEV
  (MSCHWERN on 2011-02-16)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20100730"
>20100730
  (MSCHWERN on 2010-07-31)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20090620"
>20090620
  (MSCHWERN on 2009-06-20)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081028"
>20081028
  (MSCHWERN on 2008-10-28)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021.1911"
>20081021.1911
  (MSCHWERN on 2008-10-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081021"
>20081021
  (MSCHWERN on 2008-10-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081008"
>20081008
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081007"
>20081007
  (MSCHWERN on 2008-10-08)</option>
<option
  
  value="MSCHWERN/Method-Signatures-20081006"
>20081006
  (MSCHWERN on 2008-10-06)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.11"
>0.11
  (MSCHWERN on 2008-09-27)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.10"
>0.10
  (MSCHWERN on 2008-09-22)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.05"
>0.05
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.04"
>0.04
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.03"
>0.03
  (MSCHWERN on 2008-09-21)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.02"
>0.02
  (MSCHWERN on 2007-12-26)</option>
<option
  
  value="MSCHWERN/Method-Signatures-0.01"
>0.01
  (MSCHWERN on 2007-12-26)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Method-Signatures">Method-Signatures-20170211</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 53 direct dependents &#10;          • 61 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Method-Signatures-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Method-Signatures-20170211">
    <input type="hidden" name="author" value="BAREFOOT">
    <input type="hidden" name="distribution" value="Method-Signatures">
    <button type="submit" class="favorite highlight"><span>40</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Method::Signatures.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>40</span> ++</a>
</div>
   / <span>Method::Signatures</span>
</div>
          </div>
          <main class="content">

<input id="HANDOFF" type="checkbox" class="notification-toggle-checkbox" />
<div id="metacpan_notification" class="well collapsed notify-HANDOFF">
    <label class="remove-notification" for="HANDOFF" >
      <i class="fa fa-fw fa-times black"></i>
    </label>
    <div id="metacpan_notification-container">
      <h2>Take me over?</h2>
      <div>
The maintainer of this distribution is looking for someone to take over!
        If you're interested then please contact them via
        <a href="mailto:mschwern@cpan.org,barefoot@cpan.org,barefootcoder@gmail.com?subject=Take%20over%20Method%3A%3ASignatures%3F&amp;body=Hello%2C%0A%0AI%27m%20interested%20in%20taking%20over%20the%20Method%3A%3ASignatures%20module.%20If%20you%20can%20grant%20me%20the%20privilege%20I%20will%20release%20the%20next%20version.%0A%0A">email</a>.
        <a href="https://metacpan.org/about/faq#howtoadoptadistribution"><i class="fa fa-info-circle"></i></a>
      </div>
  </div>
</div>

<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Method::Signatures.html#NAME">NAME</a></li>
  <li><a href="./Method::Signatures.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Method::Signatures.html#DESCRIPTION">DESCRIPTION</a>
    <ul>
      <li><a href="./Method::Signatures.html#Signature-syntax">Signature syntax</a>
        <ul>
          <li><a href="./Method::Signatures.html#@_">@_</a></li>
          <li><a href="./Method::Signatures.html#Named-parameters">Named parameters</a></li>
          <li><a href="./Method::Signatures.html#Aliased-references">Aliased references</a></li>
          <li><a href="./Method::Signatures.html#Invocant-parameter">Invocant parameter</a></li>
          <li><a href="./Method::Signatures.html#Defaults">Defaults</a></li>
          <li><a href="./Method::Signatures.html#Type-Constraints">Type Constraints</a></li>
          <li><a href="./Method::Signatures.html#Value-Constraints">Value Constraints</a></li>
          <li><a href="./Method::Signatures.html#Placeholder-parameters">Placeholder parameters</a></li>
          <li><a href="./Method::Signatures.html#Parameter-traits">Parameter traits</a></li>
          <li><a href="./Method::Signatures.html#Mixing-value-constraints,-traits,-and-defaults">Mixing value constraints, traits, and defaults</a></li>
          <li><a href="./Method::Signatures.html#Slurpy-parameters">Slurpy parameters</a></li>
          <li><a href="./Method::Signatures.html#The-%22yada-yada%22-marker">The &quot;yada yada&quot; marker</a></li>
          <li><a href="./Method::Signatures.html#Required-and-optional-parameters">Required and optional parameters</a></li>
          <li><a href="./Method::Signatures.html#The-@_-signature">The @_ signature</a></li>
          <li><a href="./Method::Signatures.html#The-empty-signature">The empty signature</a></li>
        </ul>
      </li>
      <li><a href="./Method::Signatures.html#Anonymous-Methods">Anonymous Methods</a></li>
      <li><a href="./Method::Signatures.html#Options">Options</a>
        <ul>
          <li><a href="./Method::Signatures.html#invocant">invocant</a></li>
          <li><a href="./Method::Signatures.html#compile_at_BEGIN">compile_at_BEGIN</a></li>
          <li><a href="./Method::Signatures.html#debug">debug</a></li>
        </ul>
      </li>
      <li><a href="./Method::Signatures.html#Differences-from-Perl-6">Differences from Perl 6</a>
        <ul>
          <li><a href="./Method::Signatures.html#Restrictions-on-named-parameters">Restrictions on named parameters</a></li>
          <li><a href="./Method::Signatures.html#Named-parameters-are-just-hashes">Named parameters are just hashes</a></li>
          <li><a href="./Method::Signatures.html#Parameters-are-copies.">Parameters are copies.</a></li>
          <li><a href="./Method::Signatures.html#Can&#39;t-use-positional-params-as-named-params">Can&#39;t use positional params as named params</a></li>
          <li><a href="./Method::Signatures.html#Addition-of-the-%5C@foo-reference-alias-prototype">Addition of the \@foo reference alias prototype</a></li>
          <li><a href="./Method::Signatures.html#Addition-of-the-@_-prototype">Addition of the @_ prototype</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="./Method::Signatures.html#PERFORMANCE">PERFORMANCE</a></li>
  <li><a href="./Method::Signatures.html#DEBUGGING">DEBUGGING</a></li>
  <li><a href="./Method::Signatures.html#EXAMPLE">EXAMPLE</a></li>
  <li><a href="./Method::Signatures.html#EXPERIMENTING">EXPERIMENTING</a></li>
  <li><a href="./Method::Signatures.html#EXTENDING">EXTENDING</a>
    <ul>
      <li><a href="./Method::Signatures.html#too_many_args_error,-named_param_error,-required_arg,-type_error,-where_error">too_many_args_error, named_param_error, required_arg, type_error, where_error</a></li>
      <li><a href="./Method::Signatures.html#signature_error">signature_error</a></li>
      <li><a href="./Method::Signatures.html#signature_error_handler">signature_error_handler</a></li>
      <li><a href="./Method::Signatures.html#type_check">type_check</a></li>
      <li><a href="./Method::Signatures.html#inject_for_type_check">inject_for_type_check</a></li>
    </ul>
  </li>
  <li><a href="./Method::Signatures.html#BUGS,-CAVEATS-and-NOTES">BUGS, CAVEATS and NOTES</a>
    <ul>
      <li><a href="./Method::Signatures.html#One-liners">One liners</a></li>
      <li><a href="./Method::Signatures.html#Close-parends-in-quotes-or-comments">Close parends in quotes or comments</a></li>
      <li><a href="./Method::Signatures.html#No-source-filter">No source filter</a></li>
      <li><a href="./Method::Signatures.html#Earlier-Perl-versions">Earlier Perl versions</a></li>
      <li><a href="./Method::Signatures.html#What-about-class-methods?">What about class methods?</a></li>
      <li><a href="./Method::Signatures.html#What-about-the-return-value?">What about the return value?</a></li>
      <li><a href="./Method::Signatures.html#How-does-this-relate-to-Perl&#39;s-built-in-prototypes?">How does this relate to Perl&#39;s built-in prototypes?</a></li>
      <li><a href="./Method::Signatures.html#Error-checking">Error checking</a></li>
      <li><a href="./Method::Signatures.html#Slurpy-parameter-restrictions">Slurpy parameter restrictions</a></li>
      <li><a href="./Method::Signatures.html#What-about...">What about...</a></li>
    </ul>
  </li>
  <li><a href="./Method::Signatures.html#THANKS">THANKS</a></li>
  <li><a href="./Method::Signatures.html#LICENSE">LICENSE</a></li>
  <li><a href="./Method::Signatures.html#SEE-ALSO">SEE ALSO</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Method::Signatures - method and function declarations with signatures and no source filter</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>    package Foo;

    use Method::Signatures;

    method new (%args) {
        return bless {%args}, $self;
    }</code></pre>

<pre><code>    method get ($key) {
        return $self-&gt;{$key};
    }

    method set ($key, $val) {
        return $self-&gt;{$key} = $val;
    }</code></pre>

<pre><code>    # Can also get type checking if you like:

    method set (Str $key, Int $val) {
        return $self-&gt;{$key} = $val;        # now you know $val is always an integer
    }</code></pre>

<pre><code>    func hello($greeting, $place) {
        print &quot;$greeting, $place!\n&quot;;
    }</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>Provides two new keywords, <code>func</code> and <code>method</code>, so that you can write subroutines with signatures instead of having to spell out <code>my $self = shift; my($thing) = @_</code></p>

<p><code>func</code> is like <code>sub</code> but takes a signature where the prototype would normally go. This takes the place of <code>my($foo, $bar) = @_</code> and does a whole lot more.</p>

<p><code>method</code> is like <code>func</code> but specifically for making methods. It will automatically provide the invocant as <code>$self</code> (<a href="./Method::Signatures.html#invocant">by default</a>). No more <code>my $self = shift</code>.</p>

<p>Also allows signatures, very similar to Perl 6 signatures.</p>

<p>Also does type checking, understanding all the types that Moose (or Mouse) would understand.</p>

<p>And it does all this with <b>no source filters</b>.</p>

<h2 id="Signature-syntax"><a id="Signature"></a>Signature syntax</h2>

<pre><code>    func echo($message) {
        print &quot;$message\n&quot;;
    }</code></pre>

<p>is equivalent to:</p>

<pre><code>    sub echo {
        my($message) = @_;
        print &quot;$message\n&quot;;
    }</code></pre>

<p>except the original line numbering is preserved and the arguments are checked to make sure they match the signature.</p>

<p>Similarly</p>

<pre><code>    method foo($bar, $baz) {
        $self-&gt;wibble($bar, $baz);
    }</code></pre>

<p>is equivalent to:</p>

<pre><code>    sub foo {
        my $self = shift;
        my($bar, $baz) = @_;
        $self-&gt;wibble($bar, $baz);
    }</code></pre>

<p>again with checks to make sure the arguments passed in match the signature.</p>

<p>The full signature syntax for each parameter is:</p>

<pre><code>          Int|Str  \:$param!  where $SM_EXPR  is ro  = $AS_EXPR  when $SM_EXPR
          \_____/  ^^\____/^  \____________/  \___/  \________/  \___________/
             |     ||   |  |        |           |        |           |
       Type_/      ||   |  |        |           |        |           |
       Aliased?___/ |   |  |        |           |        |           |
       Named?______/    |  |        |           |        |           |
       Parameter var___/   |        |           |        |           |
       Required?__________/         |           |        |           |
       Parameter constraint(s)_____/            |        |           |
       Parameter trait(s)______________________/         |           |
       Default value____________________________________/            |
       When default value should be applied_________________________/</code></pre>

<p>Every component except the parameter name (with sigil) is optional.</p>

<p><code>$SM_EXPR</code> is any expression that is valid as the RHS of a smartmatch, or else a raw block of code. See <a href="./Method::Signatures.html#Value-constraints">&quot;Value constraints&quot;</a>.</p>

<p><code>$AS_EXPR</code> is any expression that is valid as the RHS of an assignment operator. See <a href="./Method::Signatures.html#Defaults">&quot;Defaults&quot;</a>.</p>

<h3 id="@_"><a id="pod"></a><code>@_</code></h3>

<p>Other than removing <code>$self</code>, <code>@_</code> is left intact. You are free to use <code>@_</code> alongside the arguments provided by Method::Signatures.</p>

<h3 id="Named-parameters"><a id="Named"></a>Named parameters</h3>

<p>Parameters can be passed in named, as a hash, using the <code>:$arg</code> syntax.</p>

<pre><code>    method foo(:$arg) {
        ...
    }

    $object-&gt;foo( arg =&gt; 42 );</code></pre>

<p>Named parameters are optional by default.</p>

<p>Required positional parameters and named parameters can be mixed, but the named params must come last.</p>

<pre><code>    method foo( $a, $b, :$c )   # legal</code></pre>

<p>Named parameters are passed in as a hash after all positional arguments.</p>

<pre><code>    method display( $text, :$justify = &#39;left&#39;, :$enchef = 0 ) {
        ...
    }

    # $text = &quot;Some stuff&quot;, $justify = &quot;right&quot;, $enchef = 0
    $obj-&gt;display( &quot;Some stuff&quot;, justify =&gt; &quot;right&quot; );</code></pre>

<p>You cannot mix optional positional params with named params, as that leads to ambiguities.</p>

<pre><code>    method foo( $a, $b?, :$c )  # illegal

    # Is this $a = &#39;c&#39;, $b = 42 or $c = 42?
    $obj-&gt;foo( c =&gt; 42 );</code></pre>

<h3 id="Aliased-references"><a id="Aliased"></a>Aliased references</h3>

<p>A signature of <code>\@arg</code> will take an array reference but allow it to be used as <code>@arg</code> inside the method. <code>@arg</code> is an alias to the original reference. Any changes to <code>@arg</code> will affect the original reference.</p>

<pre><code>    package Stuff;
    method add_one(\@foo) {
        $_++ for @foo;
    }

    my @bar = (1,2,3);
    Stuff-&gt;add_one(\@bar);  # @bar is now (2,3,4)</code></pre>

<p>This feature requires <a href="./Data::Alias.html">Data::Alias</a> to be installed.</p>

<h3 id="Invocant-parameter"><a id="Invocant"></a>Invocant parameter</h3>

<p>The method invocant (i.e. <code>$self</code>) can be changed as the first parameter on a per-method basis. Put a colon after it instead of a comma:</p>

<pre><code>    method foo($class:) {
        $class-&gt;bar;
    }

    method stuff($class: $arg, $another) {
        $class-&gt;things($arg, $another);
    }</code></pre>

<p><code>method</code> has an implied default invocant of <code>$self:</code>, though that is configurable by setting the <a href="./Method::Signatures.html#invocant">invocant parameter</a> on the <code>use Method::Signatures</code> line.</p>

<p><code>func</code> has no invocant, as it is intended for creating subs that will not be invoked on an object.</p>

<h3 id="Defaults">Defaults</h3>

<p>Each parameter can be given a default with the <code>$arg = EXPR</code> syntax. For example,</p>

<pre><code>    method add($this = 23, $that = 42) {
        return $this + $that;
    }</code></pre>

<p>Almost any expression can be used as a default.</p>

<pre><code>    method silly(
        $num    = 42,
        $string = q[Hello, world!],
        $hash   = { this =&gt; 42, that =&gt; 23 },
        $code   = sub { $num + 4 },
        @nums   = (1,2,3),
    )
    {
        ...
    }</code></pre>

<p>Normally, defaults will only be used if the argument is not passed in at all. Passing in <code>undef</code> will override the default. That means ...</p>

<pre><code>    Class-&gt;add();            # $this = 23, $that = 42
    Class-&gt;add(99);          # $this = 99, $that = 42
    Class-&gt;add(99, undef);   # $this = 99, $that = undef</code></pre>

<p>However, you can specify additional conditions under which a default is also to be used, using a trailing <code>when</code>. For example:</p>

<pre><code>    # Use default if no argument passed
    method get_results($how_many = 1) {...}

    # Use default if no argument passed OR argument is undef
    method get_results($how_many = 1 when undef) {...}

    # Use default if no argument passed OR argument is empty string
    method get_results($how_many = 1 when &quot;&quot;) {...}

    # Use default if no argument passed OR argument is zero
    method get_results($how_many = 1 when 0) {...}

    # Use default if no argument passed OR argument is zero or less
    method get_results($how_many = 1 when sub{ $_[0] &lt;= 0 }) {...}

    # Use default if no argument passed OR argument is invalid
    method get_results($how_many = 1 when sub{ !valid($_[0]) }) {...}</code></pre>

<p>In other words, if you include a <code>when <i>value</i></code> after the default, the default is still used if the argument is missing, but is also used if the argument is provided but smart-matches the specified <i>value</i>.</p>

<p>Note that the final two examples above use anonymous subroutines to conform their complex tests to the requirements of the smartmatch operator. Because this is useful, but syntactically clumsy, there is also a short-cut for this behaviour. If the test after <code>when</code> consists of a block, the block is executed as the defaulting test, with the actual argument value aliased to <code>$_</code> (just like in a <code>grep</code> block). So the final two examples above could also be written:</p>

<pre><code>    # Use default if no argument passed OR argument is zero or less
    method get_results($how_many = 1 when {$_ &lt;= 0}) {...}

    # Use default if no argument passed OR argument is invalid
    method get_results($how_many = 1 when {!valid($_)}) } {...}</code></pre>

<p>The most commonly used form of <code>when</code> modifier is almost certainly <code>when undef</code>:</p>

<pre><code>    # Use default if no argument passed OR argument is undef
    method get_results($how_many = 1 when undef) {...}</code></pre>

<p>which covers the common case where an uninitialized variable is passed as an argument, or where supplying an explicit undefined value is intended to indicate: &quot;use the default instead.&quot;</p>

<p>This usage is sufficiently common that a short-cut is provided: using the <code>//=</code> operator (instead of the regular assignment operator) to specify the default. Like so:</p>

<pre><code>    # Use default if no argument passed OR argument is undef
    method get_results($how_many //= 1) {...}</code></pre>

<p>Earlier parameters may be used in later defaults.</p>

<pre><code>    method copy_cat($this, $that = $this) {
        return $that;
    }</code></pre>

<p>Any variable that has a default is considered optional.</p>

<h3 id="Type-Constraints"><a id="Type"></a>Type Constraints</h3>

<p>Parameters can also be given type constraints. If they are, the value passed in will be validated against the type constraint provided. Types are provided by <a href="https://metacpan.org/pod/Any::Moose">Any::Moose</a> which will load <a href="https://metacpan.org/pod/Mouse">Mouse</a> if <a href="Moose.html">Moose</a> is not already loaded.</p>

<p>Type constraints can be a type, a role or a class. Each will be checked in turn until one of them passes.</p>

<pre><code>    * First, is the $value of that type declared in Moose (or Mouse)?

    * Then, does the $value have that role?
        $value-&gt;DOES($type);

    * Finally, is the $value an object of that class?
        $value-&gt;isa($type);</code></pre>

<p>The set of default types that are understood can be found in <a href="https://metacpan.org/pod/Mouse::Util::TypeConstraints">Mouse::Util::TypeConstraints</a> (or <a href="https://metacpan.org/pod/Moose::Util::TypeConstraints">Moose::Util::TypeConstraints</a>; they are generally the same, but there may be small differences).</p>

<pre><code>    # avoid &quot;argument isn&#39;t numeric&quot; warnings
    method add(Int $this = 23, Int $that = 42) {
        return $this + $that;
    }</code></pre>

<p><a href="https://metacpan.org/pod/Mouse">Mouse</a> and <a href="Moose.html">Moose</a> also understand some parameterized types; see their documentation for more details.</p>

<pre><code>    method add(Int $this = 23, Maybe[Int] $that) {
        # $this will definitely be defined
        # but $that might be undef
        return defined $that ? $this + $that : $this;
    }</code></pre>

<p>You may also use disjunctions, which means that you are willing to accept a value of either type.</p>

<pre><code>    method add(Int $this = 23, Int|ArrayRef[Int] $that) {
        # $that could be a single number,
        # or a reference to an array of numbers
        use List::Util qw&lt;sum&gt;;
        my @ints = ($this);
        push @ints, ref $that ? @$that : $that;
        return sum(@ints);
    }</code></pre>

<p>If the value does not validate against the type, a run-time exception is thrown.</p>

<pre><code>    # Error will be:
    # In call to Class::add : the &#39;this&#39; parameter (&quot;cow&quot;) is not of type Int
    Class-&gt;add(&#39;cow&#39;, &#39;boy&#39;); # make a cowboy!</code></pre>

<p>You cannot declare the type of the invocant.</p>

<pre><code>    # this generates a compile-time error
    method new(ClassName $class:) {
        ...
    }</code></pre>

<h3 id="Value-Constraints"><a id="Value"></a>Value Constraints</h3>

<p>In addition to a type, each parameter can also be specified with one or more additional constraints, using the <code>$arg where CONSTRAINT</code> syntax.</p>

<pre><code>    method set_name($name where qr{\S+ \s+ \S+}x) {
        ...
    }

    method set_rank($rank where \%STD_RANKS) {
        ...
    }

    method set_age(Int $age where [17..75] ) {
        ...
    }

    method set_rating($rating where { $_ &gt;= 0 } where { $_ &lt;= 100 } ) {
        ...
    }

    method set_serial_num(Int $snum where {valid_checksum($snum)} ) {
        ...
    }</code></pre>

<p>The <code>where</code> keyword must appear immediately after the parameter name and before any <a href="./Method::Signatures.html#Parameter-traits">trait</a> or <a href="./Method::Signatures.html#Defaults">default</a>.</p>

<p>Each <code>where</code> constraint is smartmatched against the value of the corresponding parameter, and an exception is thrown if the value does not satisfy the constraint.</p>

<p>Any of the normal smartmatch arguments (numbers, strings, regexes, undefs, hashrefs, arrayrefs, coderefs) can be used as a constraint.</p>

<p>In addition, the constraint can be specified as a raw block. This block can then refer to the parameter variable directly by name (as in the definition of <code>set_serial_num()</code> above), or else as <code>$_</code> (as in the definition of <code>set_rating()</code>.</p>

<p>Unlike type constraints, value constraints are tested <i>after</i> any default values have been resolved, and in the same order as they were specified within the signature.</p>

<h3 id="Placeholder-parameters"><a id="Placeholder"></a>Placeholder parameters</h3>

<p>A positional argument can be ignored by using a bare <code>$</code> sigil as its name.</p>

<pre><code>    method foo( $a, $, $c ) {
        ...
    }</code></pre>

<p>The argument&#39;s value doesn&#39;t get stored in a variable, but the caller must still supply it. Value and type constraints can be applied to placeholders.</p>

<pre><code>    method bar( Int $ where { $_ &lt; 10 } ) {
        ...
    }</code></pre>

<h3 id="Parameter-traits"><a id="Parameter"></a>Parameter traits</h3>

<p>Each parameter can be assigned a trait with the <code>$arg is TRAIT</code> syntax.</p>

<pre><code>    method stuff($this is ro) {
        ...
    }</code></pre>

<p>Any unknown trait is ignored.</p>

<p>Most parameters have a default traits of <code>is rw is copy</code>.</p>

<dl>

<dt id="ro"><b>ro</b></dt>
<dd>

<p>Read-only. Assigning or modifying the parameter is an error. This trait requires <a href="https://metacpan.org/pod/Const::Fast">Const::Fast</a> to be installed.</p>

</dd>
<dt id="rw"><b>rw</b></dt>
<dd>

<p>Read-write. It&#39;s ok to read or write the parameter.</p>

<p>This is a default trait.</p>

</dd>
<dt id="copy"><b>copy</b></dt>
<dd>

<p>The parameter will be a copy of the argument (just like <code>my $arg = shift</code>).</p>

<p>This is a default trait except for the <code>\@foo</code> parameter (see <a href="./Method::Signatures.html#Aliased-references">&quot;Aliased references&quot;</a>).</p>

</dd>
<dt id="alias"><b>alias</b></dt>
<dd>

<p>The parameter will be an alias of the argument. Any changes to the parameter will be reflected in the caller. This trait requires <a href="./Data::Alias.html">Data::Alias</a> to be installed.</p>

<p>This is a default trait for the <code>\@foo</code> parameter (see <a href="./Method::Signatures.html#Aliased-references">&quot;Aliased references&quot;</a>).</p>

</dd>
</dl>

<h3 id="Mixing-value-constraints,-traits,-and-defaults"><a id="Mixing"></a><a id="Mixing-value-constraints--traits--and-defaults"></a>Mixing value constraints, traits, and defaults</h3>

<p>As explained in <a href="./Method::Signatures.html#Signature-syntax">&quot;Signature syntax&quot;</a>, there is a defined order when including multiple trailing aspects of a parameter:</p>

<ul>

<li><p>Any value constraint must immediately follow the parameter name.</p>

</li>
<li><p>Any trait must follow that.</p>

</li>
<li><p>Any default must come last.</p>

</li>
</ul>

<p>For instance, to have a parameter which has all three aspects:</p>

<pre><code>    method echo($message where { length &lt;= 80 } is ro = &quot;what?&quot;) {
        return $message
    }</code></pre>

<p>Think of <code>$message where { length &lt;= 80 }</code> as being the left-hand side of the trait, and <code>$message where { length &lt;= 80 } is ro</code> as being the left-hand side of the default assignment.</p>

<h3 id="Slurpy-parameters"><a id="Slurpy"></a>Slurpy parameters</h3>

<p>A &quot;slurpy&quot; parameter is a list or hash parameter that &quot;slurps up&quot; all remaining arguments. Since any following parameters can&#39;t receive values, there can be only one slurpy parameter.</p>

<p>Slurpy parameters must come at the end of the signature and they must be positional.</p>

<p>Slurpy parameters are optional by default.</p>

<h3 id="The-&quot;yada-yada&quot;-marker"><a id="The"></a><a id="The--yada-yada--marker"></a>The &quot;yada yada&quot; marker</h3>

<p>The restriction that slurpy parameters must be positional, and must appear at the end of the signature, means that they cannot be used in conjunction with named parameters.</p>

<p>This is frustrating, because there are many situations (in particular: during object initialization, or when creating a callback) where it is extremely handy to be able to ignore extra named arguments that don&#39;t correspond to any named parameter.</p>

<p>While it would be theoretically possible to allow a slurpy parameter to come after named parameters, the current implementation does not support this (see <a href="./Method::Signatures.html#Slurpy-parameter-restrictions">&quot;Slurpy parameter restrictions&quot;</a>).</p>

<p>Instead, there is a special syntax (colloquially known as the &quot;yada yada&quot;) that tells a method or function to simply ignore any extra arguments that are passed to it:</p>

<pre><code>    # Expect name, age, gender, and simply ignore anything else
    method BUILD (:$name, :$age, :$gender, ...) {
        $self-&gt;{name}   = uc $name;
        $self-&gt;{age}    = min($age, 18);
        $self-&gt;{gender} = $gender // &#39;unspecified&#39;;
    }

    # Traverse tree with node-printing callback
    # (Callback only interested in nodes, ignores any other args passed to it)
    $tree-&gt;traverse( func($node, ...) { $node-&gt;print } );</code></pre>

<p>The <code>...</code> may appear as a separate &quot;pseudo-parameter&quot; anywhere in the signature, but is normally placed at the very end. It has no other effect except to disable the usual &quot;die if extra arguments&quot; test that the module sets up within each method or function.</p>

<p>This means that a &quot;yada yada&quot; can also be used to ignore positional arguments (as the second example above indicates). So, instead of:</p>

<pre><code>    method verify ($min, $max, @etc) {
        return $min &lt;= $self-&gt;{val} &amp;&amp; $self-&gt;{val} &lt;= $max;
    }</code></pre>

<p>you can just write:</p>

<pre><code>    method verify ($min, $max, ...) {
        return $min &lt;= $self-&gt;{val} &amp;&amp; $self-&gt;{val} &lt;= $max;
    }</code></pre>

<p>This is also marginally more efficient, as it does not have to allocate, initialize, or deallocate the unused slurpy parameter <code>@etc</code>.</p>

<p>The bare <code>@</code> sigil is a synonym for <code>...</code>. A bare <code>%</code> sigil is also a synonym for <code>...</code>, but requires that there must be an even number of extra arguments, such as would be assigned to a hash.</p>

<h3 id="Required-and-optional-parameters"><a id="Required"></a>Required and optional parameters</h3>

<p>Parameters declared using <code>$arg!</code> are explicitly <i>required</i>. Parameters declared using <code>$arg?</code> are explicitly <i>optional</i>. These declarations override all other considerations.</p>

<p>A parameter is implicitly <i>optional</i> if it is a named parameter, has a default, or is slurpy. All other parameters are implicitly <i>required</i>.</p>

<pre><code>    # $greeting is optional because it is named
    method hello(:$greeting) { ... }

    # $greeting is required because it is positional
    method hello($greeting) { ... }

    # $greeting is optional because it has a default
    method hello($greeting = &quot;Gruezi&quot;) { ... }

    # $greeting is required because it is explicitly declared using !
    method hello(:$greeting!) { ... }

    # $greeting is required, even with the default, because it is
    # explicitly declared using !
    method hello(:$greeting! = &quot;Gruezi&quot;) { ... }</code></pre>

<h3 id="The-@_-signature"><a id="The1"></a><a id="The--_-signature"></a>The <code>@_</code> signature</h3>

<p>The @_ signature is a special case which only shifts <code>$self</code>. It leaves the rest of <code>@_</code> alone. This way you can get $self but do the rest of the argument handling manually.</p>

<p>Note that a signature of <code>(@_)</code> is exactly equivalent to a signature of <code>(...)</code>. See <a href="./Method::Signatures.html#The-yada-yada-marker">&quot;The yada yada marker&quot;</a>.</p>

<h3 id="The-empty-signature"><a id="The2"></a>The empty signature</h3>

<p>If a method is given the signature of <code>()</code> or no signature at all, it takes no arguments.</p>

<h2 id="Anonymous-Methods"><a id="Anonymous"></a>Anonymous Methods</h2>

<p>An anonymous method can be declared just like an anonymous sub.</p>

<pre><code>    my $method = method ($arg) {
        return $self-&gt;foo($arg);
    };

    $obj-&gt;$method(42);</code></pre>

<h2 id="Options">Options</h2>

<p>Method::Signatures takes some options at `use` time of the form</p>

<pre><code>    use Method::Signatures { option =&gt; &quot;value&quot;, ... };</code></pre>

<h3 id="invocant">invocant</h3>

<p>In some cases it is desirable for the invocant to be named something other than <code>$self</code>, and specifying it in the signature of every method is tedious and prone to human-error. When this option is set, methods that do not specify the invocant variable in their signatures will use the given variable name.</p>

<pre><code>    use Method::Signatures { invocant =&gt; &#39;$app&#39; };

    method main { $app-&gt;config; $app-&gt;run; $app-&gt;cleanup; }</code></pre>

<p>Note that the leading sigil <i>must</i> be provided, and the value must be a single token that would be valid as a perl variable. Currently only scalar invocant variables are supported (eg, the sigil must be a <code>$</code>).</p>

<p>This option only affects the packages in which it is used. All others will continue to use <code>$self</code> as the default invocant variable.</p>

<h3 id="compile_at_BEGIN">compile_at_BEGIN</h3>

<p>By default, named methods and funcs are evaluated at compile time, as if they were in a BEGIN block, just like normal Perl named subs. That means this will work:</p>

<pre><code>    echo(&quot;something&quot;);

    # This function is compiled first
    func echo($msg) { print $msg }</code></pre>

<p>You can turn this off lexically by setting compile_at_BEGIN to a false value.</p>

<pre><code>    use Method::Signatures { compile_at_BEGIN =&gt; 0 };</code></pre>

<p>compile_at_BEGIN currently causes some issues when used with Perl 5.8. See <a href="./Method::Signatures.html#Earlier-Perl-versions">&quot;Earlier Perl versions&quot;</a>.</p>

<h3 id="debug">debug</h3>

<p>When true, turns on debugging messages about compiling methods and funcs. See <a href="https://metacpan.org/pod/DEBUGGING">DEBUGGING</a>. The flag is currently global, but this may change.</p>

<h2 id="Differences-from-Perl-6"><a id="Differences"></a>Differences from Perl 6</h2>

<p>Method::Signatures is mostly a straight subset of Perl 6 signatures. The important differences...</p>

<h3 id="Restrictions-on-named-parameters"><a id="Restrictions"></a>Restrictions on named parameters</h3>

<p>As noted above, there are more restrictions on named parameters than in Perl 6.</p>

<h3 id="Named-parameters-are-just-hashes"><a id="Named1"></a>Named parameters are just hashes</h3>

<p>Perl 5 lacks all the fancy named parameter syntax for the caller.</p>

<h3 id="Parameters-are-copies."><a id="Parameters"></a><a id="Parameters-are-copies"></a>Parameters are copies.</h3>

<p>In Perl 6, parameters are aliases. This makes sense in Perl 6 because Perl 6 is an &quot;everything is an object&quot; language. Perl 5 is not, so parameters are much more naturally passed as copies.</p>

<p>You can alias using the &quot;alias&quot; trait.</p>

<h3 id="Can&#39;t-use-positional-params-as-named-params"><a id="Can"></a><a id="Can-t-use-positional-params-as-named-params"></a>Can&#39;t use positional params as named params</h3>

<p>Perl 6 allows you to use any parameter as a named parameter. Perl 5 lacks the named parameter disambiguating syntax so it is not allowed.</p>

<h3 id="Addition-of-the-\@foo-reference-alias-prototype"><a id="Addition"></a><a id="Addition-of-the--foo-reference-alias-prototype"></a>Addition of the <code>\@foo</code> reference alias prototype</h3>

<p>In Perl 6, arrays and hashes don&#39;t get flattened, and their referencing syntax is much improved. Perl 5 has no such luxury, so Method::Signatures added a way to alias references to normal variables to make them easier to work with.</p>

<h3 id="Addition-of-the-@_-prototype"><a id="Addition1"></a><a id="Addition-of-the--_-prototype"></a>Addition of the <code>@_</code> prototype</h3>

<p>Method::Signatures lets you punt and use @_ like in regular Perl 5.</p>

<h1 id="PERFORMANCE">PERFORMANCE</h1>

<p>There is no run-time performance penalty for using this module above what it normally costs to do argument handling.</p>

<p>There is also no run-time penalty for type-checking if you do not declare types. The run-time penalty if you do declare types should be very similar to using <a href="https://metacpan.org/pod/Mouse::Util::TypeConstraints">Mouse::Util::TypeConstraints</a> (or <a href="https://metacpan.org/pod/Moose::Util::TypeConstraints">Moose::Util::TypeConstraints</a>) directly, and should be faster than using a module such as <a href="https://metacpan.org/pod/MooseX::Params::Validate">MooseX::Params::Validate</a>. The magic of <a href="https://metacpan.org/pod/Any::Moose">Any::Moose</a> is used to give you the lightweight <a href="https://metacpan.org/pod/Mouse">Mouse</a> if you have not yet loaded <a href="Moose.html">Moose</a>, or the full-bodied <a href="Moose.html">Moose</a> if you have.</p>

<p>Type-checking modules are not loaded until run-time, so this is fine:</p>

<pre><code>    use Method::Signatures;
    use Moose;
    # you will still get Moose type checking
    # (assuming you declare one or more methods with types)</code></pre>

<h1 id="DEBUGGING">DEBUGGING</h1>

<p>One of the best ways to figure out what Method::Signatures is doing is to run your code through B::Deparse (run the code with -MO=Deparse).</p>

<p>Setting the <code>METHOD_SIGNATURES_DEBUG</code> environment variable will cause Method::Signatures to display debugging information when it is compiling signatures.</p>

<h1 id="EXAMPLE">EXAMPLE</h1>

<p>Here&#39;s an example of a method which displays some text and takes some extra options.</p>

<pre><code>  use Method::Signatures;

  method display($text is ro, :$justify = &quot;left&quot;, :$fh = \*STDOUT) {
      ...
  }

  # $text = $stuff, $justify = &quot;left&quot; and $fh = \*STDOUT
  $obj-&gt;display($stuff);

  # $text = $stuff, $justify = &quot;left&quot; and $fh = \*STDERR
  $obj-&gt;display($stuff, fh =&gt; \*STDERR);

  # error, missing required $text argument
  $obj-&gt;display();</code></pre>

<p>The display() method is equivalent to all this code.</p>

<pre><code>  sub display {
      my $self = shift;

      croak(&#39;display() missing required argument $text&#39;) unless @_ &gt; 0;
      const my $text = $_[0];

      my(%args) = @_[1 .. $#_];
      my $justify = exists $args{justify} ? $args{justify} : &#39;left&#39;;
      my $fh      = exists $args{fh}      ? $args{&#39;fh&#39;}    : \*STDOUT;

      ...
  }</code></pre>

<h1 id="EXPERIMENTING">EXPERIMENTING</h1>

<p>If you want to experiment with the prototype syntax, start with <code>Method::Signatures::parse_func</code>. It takes a method prototype and returns a string of Perl 5 code which will be placed at the beginning of that method.</p>

<p>If you would like to try to provide your own type checking, subclass <a href="./Method::Signatures.html">Method::Signatures</a> and either override <code>type_check</code> or <code>inject_for_type_check</code>. See <a href="./Method::Signatures.html#EXTENDING">&quot;EXTENDING&quot;</a>, below.</p>

<p>This interface is experimental, unstable and will change between versions.</p>

<h1 id="EXTENDING">EXTENDING</h1>

<p>If you wish to subclass Method::Signatures, the following methods are good places to start.</p>

<h2 id="too_many_args_error,-named_param_error,-required_arg,-type_error,-where_error"><a id="too_many_args_error"></a><a id="too_many_args_error--named_param_error--required_arg--type_error--where_error"></a>too_many_args_error, named_param_error, required_arg, type_error, where_error</h2>

<p>These are class methods which report the various run-time errors (extra parameters, unknown named parameter, required parameter missing, parameter fails type check, and parameter fails where constraint respectively). Note that each one calls <code>signature_error</code>, which your versions should do as well.</p>

<h2 id="signature_error">signature_error</h2>

<p>This is a class method which calls <code>signature_error_handler</code> (see below) and reports the error as being from the caller&#39;s perspective. Most likely you will not need to override this. If you&#39;d like to have Method::Signatures errors give full stack traces (similar to <code>$Carp::Verbose</code>), have a look at <a href="./Carp::Always.html">Carp::Always</a>.</p>

<h2 id="signature_error_handler">signature_error_handler</h2>

<p>By default, <code>signature_error</code> generates an error message and <code>die</code>s with that message. If you need to do something fancier with the generated error message, your subclass can define its own <code>signature_error_handler</code>. For example:</p>

<pre><code>    package My::Method::Signatures;

    use Moose;
    extends &#39;Method::Signatures&#39;;

    sub signature_error_handler {
        my ($class, $msg) = @_;
        die bless { message =&gt; $msg }, &#39;My::ExceptionClass&#39;;
    };</code></pre>

<h2 id="type_check">type_check</h2>

<p>This is a class method which is called to verify that parameters have the proper type. If you want to change the way that Method::Signatures does its type checking, this is most likely what you want to override. It calls <code>type_error</code> (see above).</p>

<h2 id="inject_for_type_check">inject_for_type_check</h2>

<p>This is the object method that actually inserts the call to <a href="./Method::Signatures.html#type_check">&quot;type_check&quot;</a> into your Perl code. Most likely you will not need to override this, but if you wanted different parameters passed into <code>type_check</code>, this would be the place to do it.</p>

<h1 id="BUGS,-CAVEATS-and-NOTES"><a id="BUGS"></a><a id="BUGS--CAVEATS-and-NOTES"></a>BUGS, CAVEATS and NOTES</h1>

<p>Please report bugs and leave feedback at &lt;bug-Method-Signatures&gt; at &lt;rt.cpan.org&gt;. Or use the web interface at <a href="http://rt.cpan.org">http://rt.cpan.org</a>. Report early, report often.</p>

<h2 id="One-liners"><a id="One"></a>One liners</h2>

<p>If you want to write &quot;use Method::Signatures&quot; in a one-liner, do a <code>-MMethod::Signatures</code> first. This is due to a bug/limitation in Devel::Declare.</p>

<h2 id="Close-parends-in-quotes-or-comments"><a id="Close"></a>Close parends in quotes or comments</h2>

<p>Because of the way <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a> parses things, an unbalanced close parend inside a quote or comment could throw off the signature parsing. For instance:</p>

<pre><code>    func foo (
        $foo,       # $foo might contain )
        $bar
    )</code></pre>

<p>is going to produce a syntax error, because the parend inside the comment is perceived as the end of the signature. On the other hand, this:</p>

<pre><code>    func foo (
        $foo,       # (this is the $foo parend)
        $bar
    )</code></pre>

<p>is fine, because the parends in the comments are balanced.</p>

<p>If you absolutely can&#39;t avoid an unbalanced close parend, such as in the following signature:</p>

<pre><code>    func foo ( $foo, $bar = &quot;)&quot; )       # this won&#39;t parse correctly</code></pre>

<p>you can always use a backslash to tell the parser that that close parend doesn&#39;t indicate the end of the signature:</p>

<pre><code>    func foo ( $foo, $bar = &quot;\)&quot; )      # this is fine</code></pre>

<p>This even works in single quotes:</p>

<pre><code>    func foo ( $foo, $bar = &#39;\)&#39; )      # default is &#39;)&#39;, *not* &#39;\)&#39;!</code></pre>

<p>although we don&#39;t recomment that form, as it may be surprising to readers of your code.</p>

<h2 id="No-source-filter"><a id="No"></a>No source filter</h2>

<p>While this module does rely on the black magic of <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a> to access Perl&#39;s own parser, it does not depend on a source filter. As such, it doesn&#39;t try to parse and rewrite your source code and there should be no weird side effects.</p>

<p>Devel::Declare only affects compilation. After that, it&#39;s a normal subroutine. As such, for all that hairy magic, this module is surprisingly stable.</p>

<h2 id="Earlier-Perl-versions"><a id="Earlier"></a>Earlier Perl versions</h2>

<p>The most noticeable is if an error occurs at compile time, such as a strict error, perl might not notice until it tries to compile something else via an <code>eval</code> or <code>require</code> at which point perl will appear to fail where there is no reason to fail.</p>

<p>We recommend you use the <a href="./Method::Signatures.html#compile_at_BEGIN">&quot;compile_at_BEGIN&quot;</a> flag to turn off compile-time parsing.</p>

<p>You can&#39;t use any feature that requires a smartmatch expression (i.e. conditional <a href="./Method::Signatures.html#Defaults">&quot;Defaults&quot;</a> and <a href="./Method::Signatures.html#Value-Constraints">&quot;Value Constraints&quot;</a>) in Perl 5.8.</p>

<p>Method::Signatures cannot be used with Perl versions prior to 5.8 because <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a> does not work with those earlier versions.</p>

<h2 id="What-about-class-methods?"><a id="What"></a><a id="What-about-class-methods"></a>What about class methods?</h2>

<p>Right now there&#39;s nothing special about class methods. Just use <code>$class</code> as your invocant like the normal Perl 5 convention.</p>

<p>There may be special syntax to separate class from object methods in the future.</p>

<h2 id="What-about-the-return-value?"><a id="What1"></a><a id="What-about-the-return-value"></a>What about the return value?</h2>

<p>Currently there is no support for declaring the type of the return value.</p>

<h2 id="How-does-this-relate-to-Perl&#39;s-built-in-prototypes?"><a id="How"></a><a id="How-does-this-relate-to-Perl-s-built-in-prototypes"></a>How does this relate to Perl&#39;s built-in prototypes?</h2>

<p>It doesn&#39;t. Perl prototypes are a rather different beastie from subroutine signatures. They don&#39;t work on methods anyway.</p>

<p>A syntax for function prototypes is being considered.</p>

<pre><code>    func($foo, $bar?) is proto($;$)</code></pre>

<h2 id="Error-checking"><a id="Error"></a>Error checking</h2>

<p>Here&#39;s some additional checks I would like to add, mostly to avoid ambiguous or non-sense situations.</p>

<p>* If one positional param is optional, everything to the right must be optional</p>

<pre><code>    method foo($a, $b?, $c?)  # legal

    method bar($a, $b?, $c)   # illegal, ambiguous</code></pre>

<p>Does <code>-&gt;bar(1,2)</code> mean $a = 1 and $b = 2 or $a = 1, $c = 3?</p>

<p>* Positionals are resolved before named params. They have precedence.</p>

<h2 id="Slurpy-parameter-restrictions"><a id="Slurpy1"></a>Slurpy parameter restrictions</h2>

<p>Slurpy parameters are currently more restricted than they need to be. It is possible to work out a slurpy parameter in the middle, or a named slurpy parameter. However, there&#39;s lots of edge cases and possible nonsense configurations. Until that&#39;s worked out, we&#39;ve left it restricted.</p>

<h2 id="What-about..."><a id="What2"></a><a id="What-about"></a>What about...</h2>

<p>Method traits are in the pondering stage.</p>

<p>An API to query a method&#39;s signature is in the pondering stage.</p>

<p>Now that we have method signatures, multi-methods are a distinct possibility.</p>

<p>Applying traits to all parameters as a short-hand?</p>

<pre><code>    # Equivalent?
    method foo($a is ro, $b is ro, $c is ro)
    method foo($a, $b, $c) is ro</code></pre>

<p><a href="https://metacpan.org/pod/Role::Basic">Role::Basic</a> roles are currently not recognized by the type system.</p>

<p>A &quot;go really fast&quot; switch. Turn off all runtime checks that might bite into performance.</p>

<p>Method traits.</p>

<pre><code>    method add($left, $right) is predictable   # declarative
    method add($left, $right) is cached        # procedural
                                               # (and Perl 6 compatible)</code></pre>

<h1 id="THANKS">THANKS</h1>

<p>Most of this module is based on or copied from hard work done by many other people.</p>

<p>All the really scary parts are copied from or rely on Matt Trout&#39;s, Florian Ragwitz&#39;s and Rhesa Rozendaal&#39;s <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a> work.</p>

<p>The prototype syntax is a slight adaptation of all the excellent work the Perl 6 folks have already done.</p>

<p>The type checking and method modifier work was supplied by Buddy Burden (barefootcoder). Thanks to this, you can now use Method::Signatures (or, more properly, <a href="https://metacpan.org/pod/Method::Signatures::Modifiers">Method::Signatures::Modifiers</a>) instead of <a href="https://metacpan.org/pod/MooseX::Method::Signatures">MooseX::Method::Signatures</a>, which fixes many of the problems commonly attributed to <a href="https://metacpan.org/pod/MooseX::Declare">MooseX::Declare</a>.</p>

<p>Value constraints and default conditions (i.e. &quot;where&quot; and &quot;when&quot;) were added by Damian Conway, who also rewrote some of the signature parsing to make it more robust and more extensible.</p>

<p>Also thanks to Matthijs van Duin for his awesome <a href="./Data::Alias.html">Data::Alias</a> which makes the <code>\@foo</code> signature work perfectly and <a href="./Sub::Name.html">Sub::Name</a> which makes the subroutine names come out right in caller().</p>

<p>And thanks to Florian Ragwitz for his parallel <a href="https://metacpan.org/pod/MooseX::Method::Signatures">MooseX::Method::Signatures</a> module from which I borrow ideas and code.</p>

<h1 id="LICENSE">LICENSE</h1>

<p>The original code was taken from Matt S. Trout&#39;s tests for <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a>.</p>

<p>Copyright 2007-2012 by Michael G Schwern &lt;schwern@pobox.com&gt;.</p>

<p>This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<p>See <i>http://www.perl.com/perl/misc/Artistic.html</i></p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="https://metacpan.org/pod/MooseX::Method::Signatures">MooseX::Method::Signatures</a> for an alternative implementation.</p>

<p><a href="https://metacpan.org/pod/Perl6::Signature">Perl6::Signature</a> for a more complete implementation of Perl 6 signatures.</p>

<p><a href="https://metacpan.org/pod/Method::Signatures::Simple">Method::Signatures::Simple</a> for a more basic version of what Method::Signatures provides.</p>

<p><a href="https://metacpan.org/pod/Function::Parameters">Function::Parameters</a> for a subset of Method::Signature&#39;s features without using <a href="https://metacpan.org/pod/Devel::Declare">Devel::Declare</a>.</p>

<p><a href="https://metacpan.org/pod/signatures">signatures</a> for <code>sub</code> with signatures.</p>

<p>Perl 6 subroutine parameters and arguments - <a href="http://perlcabal.org/syn/S06.html#Parameters_and_arguments">http://perlcabal.org/syn/S06.html#Parameters_and_arguments</a></p>

<p><a href="https://metacpan.org/pod/Moose::Util::TypeConstraints">Moose::Util::TypeConstraints</a> or <a href="https://metacpan.org/pod/Mouse::Util::TypeConstraints">Mouse::Util::TypeConstraints</a> for further details on how the type-checking works.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Method::Signatures, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Method::Signatures</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Method::Signatures</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Method::Signatures.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
